package com.lbj.mvvm.work

import com.lbj.mvvm.network.AppException

sealed class Work<out T> {
    companion object {
        fun <T> onSuccess(data: T,code: Int = 200, msg: String = ""): Work<T> =
            Success(data, code, msg)

        fun <T> onLoading(loadingMessage: String): Work<T> = Loading(loadingMessage)
        fun <T> onError(error: AppException): Work<T> = Error(error)
    }

    data class Loading(val loadingMessage: String) : Work<Nothing>()
    data class Success<out T>(val data: T, val code: Int, val msg: String) : Work<T>()
    data class Error(val error: AppException) : Work<Nothing>()
}